<template>
  <div>
    <div class="hearder" @click="run">
      <div v-if="loginStatus" style="display: flex;flex-direction: column;justify-content: center;align-items: center;">
        <img style="width:65px;border-radius: 50%;" :src="userInfo.imgUrl" />
        <div style="color:white">{{userInfo.nickName}}</div>
      </div>
      <div v-else class="dl">
        <!-- <div class="tx"><img :src="src" "></div> -->
        <div style="color:white;font-size:20px;background-color:  red;border-radius:10px">登录/注册</div>
      </div>
    </div>
    <div class="tab">
      <div style="margin-bottom:3%;border-bottom:1px solid black;border-top:1px solid black" @click="toAddr">地址管理</div>
      <div style="margin-bottom:3%;border-bottom:1px solid black;border-top:1px solid black" v-if="loginStatus" @click="USER_DELET">退出登录</div>
    </div>
  </div>
</template>

<script>
import {mapState,mapMutations} from 'vuex'
export default {
  data(){
    return{
      src:'/tx.webp'
    }
  },
  computed:{
    ...mapState({
      loginStatus:state=>state.user.loginStatus,
      userInfo:state=>state.user.userInfo,
    })
  },
  methods:{
    ...mapMutations(['USER_DELET']),
    run(){
      this.$router.push({name:'login'}) 
    },
    toAddr(){
      this.$router.push('/addr') 
    }
  }
}
</script>

<style lang="scss" scoped>
  .tx{
    width: 70px;
    height: 70px;
  }
  .dl{
    display: flex;
    align-items: center;
  }
  .hearder{
    display: flex;
    justify-content: space-around;
    align-items: center;
    background-color: chocolate ;
    height: 130px;
  }
  .tab{
    margin-top: 3%;
  }
</style>